package cn.xfdzx.android.apps.shop.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.fragment.home.response.HomeNearShop;

public class NearGoodChildAdapter extends BaseQuickAdapter<HomeNearShop.DataBean.GoodsBean, BaseViewHolder> {

    RoundedCorners roundedCorners;
    RequestOptions options;
    public NearGoodChildAdapter( @Nullable List<HomeNearShop.DataBean.GoodsBean> data) {
        super(R.layout.item_near_shop_child_goods_layout, data);
        roundedCorners = new RoundedCorners(5);
        options = RequestOptions.bitmapTransform(roundedCorners).override(200, 200);
        options.placeholder(R.drawable.icon_defult)//图片加载出来前，显示的图片
                .fallback(R.drawable.icon_defult) //url为空的时候,显示的图片
                .error(R.drawable.icon_defult);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeNearShop.DataBean.GoodsBean item) {
        Glide.with(mContext).load(item.getThumb()).apply(options.transform(new CenterCrop(), roundedCorners)).into((ImageView) helper.getView(R.id.iv_image));

        helper.setText(R.id.tv_price,"¥"+item.getMarketprice());

    }
}
